//@author A0086393U
package rightnow.ui.widgets;

import java.util.Observable;
import java.util.Observer;

import javafx.scene.control.Label;
import rightnow.logic.FeedbackProvider;
import rightnow.ui.widgets.QuickHelp;

/**
 * This class is a mock feedback controller used in the FeedbackProviderTest,
 * so FXML is not required to be called.
 *
 */
public class MockFeedbackController implements Observer {	

	Label feedbackLabel;

	public MockFeedbackController() {
		feedbackLabel = new Label();
		
		FeedbackProvider.getInstance().addObserver(this);
	}
	
	public void update(Observable obs, Object arg) {
		if (obs == QuickHelp.getInstance()) {
			feedbackLabel.setText(QuickHelp.getInstance().getMessage());
		}
		
		if (obs == FeedbackProvider.getInstance()) {
			FeedbackProvider fp = FeedbackProvider.getInstance();
			if (fp.hasFeedbackMsgChanged()) {
				feedbackLabel.setText(fp.getFeedbackMessage());
			}
		}
	}
	
	public String getLabelText() {
		return feedbackLabel.getText();
	}
}
